

package com.googlecode.flac4j.format.util;


import java.util.zip.Checksum;


/**
 *
 * @author Jin Kwon <jinahya at gmail.com>
 */
public class CRC16 implements Checksum {


    @Override
    public long getValue() {
        return value & 0xFFFFL;
    }


    @Override
    public void reset() {
        value = 0x0000;
    }


    @Override
    public void update(final int b) {
        value = jFLACCRC16.update((byte) (b & 0xFF), value);
    }


    @Override
    public void update(final byte[] b, final int off, final int len) {
        for (int i = 0; i < len; i++) {
            update(b[off + i] & 0xFF);
        }
    }


    private short value;


}

